package controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;

import model.SaveModel;
import view.AddWindow;
import view.ContactWindow;
import view.MainWindow;

/**
 * This controller call the model which save the new contact added by the user to the text file
 * @author Marie Morin
 *
 */
public class SaveController implements ActionListener{
	
	private MainWindow w;
	private AddWindow a;
	
	public SaveController(MainWindow w, AddWindow a){
		
		this.w = w;
		this.a = a;
	}

	
	/**
	 *  This function is called when the user click on the button Save on the add page
	 */
	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		
		try {
			SaveModel addModel = new SaveModel(a);
		} catch (FileNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (UnsupportedEncodingException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
		w.setLayoutNull();

		
	}

}
